package com.louisgeek.myscanlogin;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

public class RemoteActivity extends AppCompatActivity {

    Button id_btn_up;
    Button id_btn_left;
    Button id_btn_down;
    Button id_btn_right;

    Button id_btn_ok;
    Button id_btn_menu;
    Button id_btn_home;
    Button id_btn_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_remote);

        id_btn_up = findViewById(R.id.id_btn_up);
        id_btn_left = findViewById(R.id.id_btn_left);
        id_btn_down = findViewById(R.id.id_btn_down);
        id_btn_right = findViewById(R.id.id_btn_right);

        id_btn_ok = findViewById(R.id.id_btn_ok);
        id_btn_menu = findViewById(R.id.id_btn_menu);
        id_btn_home = findViewById(R.id.id_btn_home);
        id_btn_back = findViewById(R.id.id_btn_back);


        id_btn_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_DPAD_UP));
            }
        });
        id_btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_DPAD_LEFT));
            }
        });
        id_btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_DPAD_RIGHT));
            }
        });
        id_btn_down.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_DPAD_DOWN));
            }
        });

        id_btn_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_ENTER));
            }
        });
        id_btn_menu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_MENU));
            }
        });
        id_btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_BACK));
            }
        });
        id_btn_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyApplication.getIn().getTcpClient().send(String.valueOf(KeyEvent.KEYCODE_HOME));
            }
        });
    }


}
